<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<link rel="stylesheet" href="../lib/jqueryui/css/custom-theme/jquery-ui-1.8.23.custom.css" />
<script language="javascript" type="text/javascript" src="../lib/jqueryui/js/jquery-1.8.0.min.js"></script>
<script language="javascript" type="text/javascript" src="../lib/jqueryui/js/jquery-ui-1.8.23.custom.min.js"></script>
<script language="javascript" type="text/javascript" src="../lib/hotkeys/jquery.hotkeys-0.7.9.js"></script>
</head>

<body>
<div id="ok" style="border:red thin solid;">
</div>
<input type="button" id="btnok" value="Click it" />
<script language="javascript" type="text/javascript">
var arrKeys=new Array();
function k1(e)
{
	alert("OK 1");
	console.log(window.onkeydown);
}

function k2(e)
{
	alert("OK 2");
	console.log(window.onkeydown);
}

$(document).on("keydown",k1);
$("#btnok").click(function(){
	$("#ok").dialog({
		focus:function(){
			console.log("Focus");
			$(document).off("keydown");
			$(document).on("keydown",k2);
		},
		close:function(){
			$(document).off("keydown");
			$(document).on("keydown",k1);
		},
		buttons:{
			"OK":function(){alert("OK button");},
			"Canecl":function(){alert("Cancel button");}
		}
	});
});
</script>
</body>
</html>